﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace JqueryNet.FormControl.FormWebControl
{
    public class JHyperLink : JWebControl
    {
        HyperLink hyperLink;
        public JHyperLink(HyperLink hyperLink)
            : base(hyperLink)
        {
            this.hyperLink = hyperLink;
        }

        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "text":
                case "value":
                    Value = hyperLink.Text;
                    return;
                case "tooltip":
                case "title":
                    Value = hyperLink.ToolTip;
                    return;
                case "width":
                    Value = hyperLink.Width;
                    return;
                case "target":
                    Value = hyperLink.Target;
                    return;
                case "navigateurl":
                case "url":
                    Value = hyperLink.NavigateUrl;
                    return;
                case "imageurl":
                case "image":
                    Value = hyperLink.ImageUrl;
                    return;
                case "height":
                    Value = hyperLink.Height;
                    return;
                default:
                    base.Attr(key);
                    return;
            }

        }

        public override void Attr(string key, string value)
        {
            int b;
            int.TryParse(value, out b);
            switch (key.ToLower())
            {
                case "text":
                case "value":
                    hyperLink.Text = value;
                    return;
                case "tooltip":
                case "title":
                    hyperLink.ToolTip = value;
                    return;
                case "width":
                    hyperLink.Width = b;
                    return;
                case "target":
                    hyperLink.Target = value;
                    return;
                case "navigateurl":
                case "url":
                    hyperLink.NavigateUrl = value;
                    return;
                case "imageurl":
                case "image":
                    hyperLink.ImageUrl = value;
                    return;
                case "height":
                    hyperLink.Height = b;
                    return;
                default:
                    base.Attr(key, value); return;
            }
        }

        public override void Val()
        {
            Value = hyperLink.Text;
        }

        public override void Val(string value)
        {
            hyperLink.Text = value;
        }
    }
}
